package	com.yunfeng.aolin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yunfeng.aolin.entity.OrderScheduling;
import com.yunfeng.aolin.dao.OrderSchedulingDAO;
import com.yunfeng.aolin.service.OrderSchedulingService;
import com.yunfeng.common.util.Page;
import com.yunfeng.common.util.PageUtils;

@Service
@Transactional
public class OrderSchedulingServiceImpl implements OrderSchedulingService {
	
	@Autowired
	private OrderSchedulingDAO orderSchedulingDAO;

	/**   
	 * @param id
	 * @return  
	 * @see com.yunfeng.aolin.service.OrderSchedulingService#get(java.lang.Long)  
	 */ 
	@Override
	public OrderScheduling get(Long id) {
		return orderSchedulingDAO.findOne(id);
	}

	/**   
	 * @param orderScheduling  
	 * @see com.yunfeng.aolin.service.OrderSchedulingService#saveOrUpdate(com.yunfeng.aolin.entity.OrderScheduling)  
	 */
	@Override
	public void saveOrUpdate(OrderScheduling orderScheduling) {
		orderSchedulingDAO.save(orderScheduling);
	}

	/**   
	 * @param id  
	 * @see com.yunfeng.aolin.service.OrderSchedulingService#delete(java.lang.Long)  
	 */
	@Override
	public void delete(Long id) {
		orderSchedulingDAO.delete(id);
	}

	@Override
	public List<OrderScheduling> findAll() {
		// TODO Auto-generated method stub
		return orderSchedulingDAO.findAll();
	}

	/**   
	 * @param page
	 * @return  
	 * @see com.yunfeng.aolin.service.OrderSchedulingService#findAll(com.ketayao.ketacustom.util.dwz.Page)  
	 */
	@Override
	public List<OrderScheduling> findAll(Page page) {
		org.springframework.data.domain.Page<OrderScheduling> springDataPage = orderSchedulingDAO.findAll(PageUtils.createPageable(page));
		page.setTotalCount(springDataPage.getTotalElements());
		return springDataPage.getContent();
	}
	
	/**   
	 * @param page
	 * @param liaohao
	 * @return  
	 * @see com.yunfeng.aolin.service.OrderSchedulingService#findByLiaohao(com.ketayao.ketacustom.util.dwz.Page, java.lang.String)  
	 */
	@Override
	public List<OrderScheduling> findByLiaohao(Page page, String liaohao) {
		org.springframework.data.domain.Page<OrderScheduling> springDataPage = orderSchedulingDAO.findByLiaohaoContaining(liaohao, PageUtils.createPageable(page));
		page.setTotalCount(springDataPage.getTotalElements());
		return springDataPage.getContent();
	}
	
	/**
	 * 
	 * @param specification
	 * @param page
	 * @return
	 * @see com.yunfeng.aolin.service.OrderSchedulingService#findByExample(org.springframework.data.jpa.domain.Specification, com.ketayao.ketacustom.util.dwz.Page)	
	 */
	@Override
	public List<OrderScheduling> findByExample(
			Specification<OrderScheduling> specification, Page page) {
		org.springframework.data.domain.Page<OrderScheduling> springDataPage = orderSchedulingDAO.findAll(specification, PageUtils.createPageable(page));
		page.setTotalCount(springDataPage.getTotalElements());
		return springDataPage.getContent();
	}
}
